package com.xxh.dataaccess.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xxh.dataaccess.dao.UserCollectionDao;
import com.xxh.dataaccess.entity.UserCollection;
import com.xxh.dataaccess.service.UserCollectionService;
import org.springframework.stereotype.Service;

import java.util.HashMap;

/**
 * (UserCollection)表服务实现类
 *
 * @author makejava
 * @since 2021-02-12 16:49:39
 */
@Service("userCollectionService")
public class UserCollectionServiceImpl extends ServiceImpl<UserCollectionDao, UserCollection> implements UserCollectionService {


    @Override
    public boolean isFavorited(String bv, Integer uid) {

        HashMap<String, Object> map = new HashMap<>();
        map.put("bv", bv);
        map.put("uid", uid);
        QueryWrapper<UserCollection> wrapper = new QueryWrapper<UserCollection>().allEq(map);
        UserCollection collection = baseMapper.selectOne(wrapper);
        if (collection == null) {
            return false;
        } else {
            return true;
        }
    }


    @Override
    public boolean isFavorited(Integer mid, Integer uid) {
        HashMap<String, Object> map = new HashMap<>();
        map.put("mid", mid);
        map.put("uid", uid);
        QueryWrapper<UserCollection> wrapper = new QueryWrapper<UserCollection>().allEq(map);
        UserCollection collection = baseMapper.selectOne(wrapper);
        if (collection == null) {
            return false;
        } else {
            return true;
        }
    }
}
